package com.junzhiit.nengji.cms.web.util.tools;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

public class NumberUtils {
	
	public static String getOrderlNumber(){
		int max = 99999;
        int min = 10000;
        Random random = new Random();
        int num = random.nextInt(99999)%(max-min+1) + min;
        String number = String.valueOf(num) + String.valueOf(new Date().getTime()).substring(2, 13);
		return number;
	}
	
	public static String getMchBillno(){
		int max = 99999;
        int min = 10000;
        Random random = new Random();
        int num = random.nextInt(99999)%(max-min+1) + min;
        String number = String.valueOf(num) + String.valueOf(new Date().getTime()).substring(3, 13);
		return number;
	}
	
	public static String getSystemCode(long value){
		DecimalFormat df =  new DecimalFormat("0000");
		return df.format(value);
	}
	
	/**
	 * 随机生成字符串：26英文字母大小写与数字
	 * @param count 个数
	 * @param length 长度
	 * @return
	 */
	public static List<String> getStringRandom(int count,int length) {
		List<String> list = new ArrayList<>();
		for(int i = 0;i < count; i++){
			StringBuilder code = new StringBuilder();
			Random random = new Random();
			//参数length，表示生成几位随机数
			for (int n = 0; n < length; n++) {
				String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
				// 输出字母还是数字
				if ("char".equalsIgnoreCase(charOrNum)) {
					// 输出是大写字母还是小写字母
					int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
					code.append((char) (random.nextInt(26) + temp));
				} else if ("num".equalsIgnoreCase(charOrNum)) {
					code.append(String.valueOf(random.nextInt(10)));
				}
			}
			list.add(code.toString());
		}
		return list;
	}

	
	public static void main(String[] args) {
		List<String> list = getStringRandom(1000,12);
		for(String code : list){
			System.out.println(code);
		}
	}
}
